package com.camelot.boot.module.system.api.aicompany;

import com.camelot.boot.framework.common.util.object.BeanUtils;
import com.camelot.boot.module.system.dal.dataobject.company.CompanyDO;
import com.camelot.boot.module.system.service.company.CompanyService;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

@Service
public class CompanyApiImpl implements CompanyApi{

    @Resource
    private CompanyService companyService;

    @Override
    public CompanyRespDTO getById(Long companyId) {
        if (companyId == null){
            return null;
        }

        CompanyDO company = companyService.getCompany(companyId);
        if (company == null){
            return null;
        }
        return BeanUtils.toBean(company,CompanyRespDTO.class);
    }

    @Override
    public List<CompanyRespDTO> listByIds(Collection<Long> ids) {
        if (CollectionUtils.isEmpty(ids)){
            return List.of();
        }

        List<CompanyDO> companyList = companyService.listByIds(ids);
        if (CollectionUtils.isEmpty(companyList)){
            return List.of();
        }
        return BeanUtils.toBean(companyList,CompanyRespDTO.class);
    }
}
